package demo4;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: XMQ
 * Date: 2022-05-16
 * Time: 20:10
 */
//接口
abstract class Animal{
    public String name;
    public int age;
    public Animal(String name,int age){
        this.name = name;
        this.age = age;
    }
    public abstract void eat();

}
interface IRunning{
    void iRun();
}
interface IFlying{
    void iFly();
}
interface ISwimming{
    void ISwim();
}
//能跑，能游泳
class Dog extends Animal implements IRunning,ISwimming{
    public Dog(String name, int age) {
        super(name, age);
    }

    @Override
    public void eat() {
        System.out.println(name+" 吃狗粮");
    }

    @Override
    public void iRun() {
        System.out.println(name+"正在用四条腿跑");
    }

    @Override
    public void ISwim() {
        System.out.println(name+"正在用四条腿在狗刨");
    }
}
//能跑，能飞
class Bird extends Animal implements IFlying,IRunning{
    public Bird(String name,int age){
        super(name,age);
    }
    @Override
    public void eat() {
        System.out.println(name + "吃鸟粮");
    }

    @Override
    public void iFly() {
        System.out.println(name + "正在用翅膀飞");
    }

    @Override
    public void iRun() {
        System.out.println(name+ "正在用两条腿跑");
    }
}
class Duck extends Animal implements IRunning,IFlying,ISwimming{

    public Duck(String name, int age) {
        super(name, age);
    }

    @Override
    public void eat() {
        System.out.println(name + "正在吃鸭粮");
    }

    @Override
    public void iRun() {
        System.out.println(name + "正在用大脚掌跑");
    }

    @Override
    public void iFly() {
        System.out.println(name + "正在用翅膀飞");
    }

    @Override
    public void ISwim() {
        System.out.println(name + "正在用大脚掌游泳");
    }
}
public class Test {

    public static void swim(ISwimming swimming){
        swimming.ISwim();
    }
    public static void main(String[] args) {
        swim(new Dog("修狗",3));
        swim(new Duck("唐老鸭",1));
    }
    public static void fly(IFlying flying){
        flying.iFly();
    }

    public static void main3(String[] args) {
        fly(new Bird("鸟儿",2));
        fly(new Duck("唐老鸭",1));

    }
    public static void walk(IRunning running){
        running.iRun();
    }

    public static void main2(String[] args) {
        walk(new Dog("修狗",3));
        walk(new Bird("鸟儿",2));
        walk(new Duck("唐老鸭",1));

    }
    public static void eat(Animal animal){
        animal.eat();
    }
    public static void main1(String[] args) {
        eat(new Dog("修狗",3));
        eat(new Bird("鸟儿",2));
        eat(new Duck("唐老鸭",1));

    }
}
